function playerInPosession = PlayerInPossession(P,S, mode)

B=S{1};
B_X=B{1}(1);
B_Y=B{1}(2);

P_X=P{1}(1);
P_Y=P{1}(2);
P_theta=P{1}(3);

if(((round(B_X)==P_X && round(B_Y)==P_Y) || ...    %over the ball
            (round(B_X)==P_X+sign(round(cos(P_theta/180*pi))) && round(B_Y)==P_Y+sign(round(sin(P_theta/180*pi)))) || ...    %in one of the three kicking cells
            (round(B_X)==P_X+sign(round(cos((P_theta+45)/180*pi))) && round(B_Y)==P_Y+sign(round(sin((P_theta+45)/180*pi)))) || ...
            (round(B_X)==P_X+sign(round(cos((P_theta-45)/180*pi))) && round(B_Y)==P_Y+sign(round(sin((P_theta-45)/180*pi))))))
   playerInPosession = true;
else
   playerInPosession = false;
end

end